<?php if($export_to_word) {ob_end_clean(); ob_start();} ?>
<style type="text/css">
    table thead td{ font-weight:bold; }
</style>
<?php $results = $sf_data->getRaw('results') ?>
<?php if(count($results) != 0) { ?>
<?php $show_for_array = $sf_data->getRaw('show_for_array') ?>
<div id="sf_admin_container" class="report_results">
    <div class="save_as_word"><a target="_blank" href="<?php echo url_for('smart_report/index?export=1') ?>"><img src="<?php echo image_path('word_icon.gif') ?>"/></a></div>
    <br/>
    <?php if($export_to_word) ob_start() ?>
    <table cellpadding="2" cellspacing="0" dir="rtl" border="1" align="center" width="100%">
        <thead>
            <?php foreach ($results as $k => $v) { ?>
                <tr>
                    <td><?php echo __('Number') ?></td>
                    <?php foreach ($v as $k2 => $one) { ?>
                        <?php if ($k2 == 'id' || $k2 == 'prog_id') continue ?>
                        <td>
                            <?php echo isset($labels[$k2]) ? __($labels[$k2]) : $k2 ?>
                        </td>
                    <?php } ?>
                </tr>
                <?php break;
            } ?>
        </thead>
        <tbody>
            <?php foreach ($results as $k => $v) { ?>
                <tr>
                    <td><?php echo $k + 1 ?></td>
                    <?php foreach ($v as $k3 => $one) { ?>
                        <?php if ($k3 == 'id' || $k3 == 'prog_id') continue ?>
                        <td>
                            <?php
                            if (isset($show_for_array[$k3]) && $show_for_array[$k3] == '[COUNT]') {
                                $c = 0;
                                foreach ($one as $assign_status) {
                                    if ($assign_status['assign_status'] == '2') {
                                        $c++;
                                    }
                                }
                                echo $c;
                                continue;
                            }
                            if (isset($one[0]) && is_array($one[0])) {
                                foreach ($one as $kk => $vv) {
                                    echo $vv[$show_for_array[$k3]] . '<br/>';
                                }
                            } else if (is_array($one)) {
                                echo isset($one[$show_for_array[$k3]]) ? $one[$show_for_array[$k3]] : '';
                            } else {
                                echo is_bool($one) ? ($one ? __('yes') : __('no') ) : $one;
                            }
                            ?>
                        </td>
                    <?php } ?>
                </tr>
            <?php } ?>
        </tbody>
    </table>
    <?php if($export_to_word) { $html = ob_get_clean(); die(globals::wordify($html)); } ?>
</div>
<?php } else { ?>
<center><?php echo __('no results found') ?></center>
<?php } ?>
